#include <iostream>
#include <string>
#include <cstring>
#include <stack>
using namespace std;

typedef string newType;

typedef struct BTree
{
	newType data;
	struct BTree* lchild, * rchild;
}BTree;


void CreateBTree(BTree* &h)
{
	h = new BTree;//申请空间
	cin >> h->data;
	if (h->data == "#")return;
	CreateBTree(h->lchild);
	CreateBTree(h->rchild);
}

void OutTree(BTree* h, int len) //右中左遍历
{
	if (h->data == "#") return;
	OutTree(h->rchild, len + 4);
	for (int i = 1; i <= len; i++) cout << " "; //打印空格数目
	cout << h->data << endl;
	OutTree(h->lchild, len + 4);
}

int main()
{
	while (true)
	{
		BTree* h;
		h = new BTree;
		if (!(cin >> h->data)) break; //不输入直接退出
		CreateBTree(h->lchild);
		CreateBTree(h->rchild);
		OutTree(h, 0);
		cout << endl;
	}
	return 0;
}


//数据测试
//A ST C # # D 10 # G # # F # # #
//4 2 1 # # 3 # # 5 # 6 # #